<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
  <base target="_self"/>
    <link rel="stylesheet" type="text/css" href="<%=path %>/web/style/layout.css" />
    <script type="text/javascript" src="<%=path %>/jqGrid/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<%=path %>/jslib/jquery.validate.min.js"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/My97DatePicker/WdatePicker.js" defer="defer"></script>
    <script type='text/javascript' src="<%=request.getContextPath() %>/jslib/jquery.form.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath() %>/jslib/additional-methods.js"></script>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/demo.css">
	<script type="text/javascript" src="<%=request.getContextPath() %>/jslib/jquery-easyui-1.4.1/jquery.easyui.min.js"></script>
    <c:if test="${requestScope.message!=null}">
		<script type="text/javascript">
 	 		     alert('<c:out value="${requestScope.message}"></c:out>');
 	 		     window.close();
 		</script>
	</c:if>
	
    <script type="text/javascript">
    var api = frameElement.api, W = api.opener;
    var stateValue="";
    $().ready(function(){
            
			var options = {
		  	    url:'<%=request.getContextPath() %>/gongyingshang!addGongyingshang.action',
		  	     beforeSubmit: function() {
		   				return checking();
		    			},
		  	    dataType:'json',
		  	    success: function(data) {
		  	    //alert(data);
		  	      if(data.result=='success'){
					alert("添加成功");
				//	window.close();
					api.close();
					W.refreshIt();
		  	      }
		  	    }};
		$('#saveBtn').click(function(){
			    	$('#pageFrom').ajaxSubmit(options);
	 	            return false;
    	 });
    	$('#closeBtn').click(function(){
    		api.close();
			//window.close();
		});
		
	});
	
   	function checking(){
   		var flag = true;
		var gongyingshangname = $.trim($("#gongyingshangname").val());
//		var lianxifangshi = $.trim($("#lianxifangshi").val());
		if(gongyingshangname ==null || gongyingshangname == "" ){
			alert("供应商名称不能为空！");
			$("#gongyingshangname").focus();
    		return false;
		}
//		if(lianxifangshi != null && lianxifangshi != ""){
//		}
		
	}
	 
	function checkExp(inputData){ 
		var regEx = new RegExp(/^(([^\^\.<>%&',:;=?$"'#@!~\]\[{}【】￥（）！·‘’”“。，、？：；—|\/\\/`\|])*)$/);
		var result = inputData.match(regEx);
		if (result == null) {
			return false;
		}
		return true;
	}
	function checkNum(inputData){
		var sNumber;
	    sNumber=Number(inputData);
	    if (isNaN(inputData)){
	       return false;
	     }
	    return true;
	}
	function countlen1(textarea){
	       var elem = event.relatedTarget || event.srcElement || event.target ||event.currentTarget;    
	        if(event.keyCode!=8)
			{
			  if (textarea.value.length> 249){
			        alert("最多为250个字符,字符输入超出限制!");
			        textarea.value=textarea.value.substring(0,249);
			    }
			    return true;
	 	    }
	}
		
	  //选择部门
	function selectdept(id)
	{
		var datas = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/choose_organizationIndex.jsp?temp="+Math.round(Math.random()*10000),'',"dialogWidth=900px;dialogHeight=550px");
		if(typeof(datas) == 'undefined'){
		}else{
			var json1 = eval('(' + datas + ')');
			 document.getElementById("dept_"+id).value = json1.ORG_NAME;
			 document.getElementById(id).value = json1.ORG_ID;
		}
	}
	
	//选择人员
	function selectperson(id)
	{
		 var users = window.showModalDialog("<%=request.getContextPath() %>/resource/choose/chooseAllUser.jsp", window, "dialogWidth:900px;status:no;dialogHeight:500px");
    	if (users != null) {
    		var userIds = [];
            var userNames = [];
            for(var i=0;i<users.length;i++){
                userIds.push(users[i]['userid']);
                userNames.push(users[i]['username']);
            }
			    $("#"+id).val(userNames.join());
		     //   $("#"+id+"_id").val(userIds.join());
		   }
	}
	function changevalue(id){
	 	
	 	var flag = "0";
	 	if(id == 1){
	 		var fileValue = document.getElementById("file1").value;
	 		var a=fileValue.lastIndexOf("\\");
	 		var filename = fileValue.substring(a+1);
			document.getElementById("gongyingshangzizhi").value=filename;
			flag = "1";
		}else if(id == 2){
		    var fileValue = document.getElementById("file2").value;
	 		var a=fileValue.lastIndexOf("\\");
	 		var filename = fileValue.substring(a+1);
			document.getElementById("gongyingshangpingjia").value=filename;
			flag = "2";
		}
		document.getElementById("flag").value=flag;
	}

   </script>
 	<style type="text/css">
 		body{
 			background:#ffffff; background-image:url(images/);
 		}
   		html{
		    overflow-x: hidden;
			overflow-y: hidden;
		}  	
		.formTableNew textarea{border: 1px solid #999;padding: 5px;width: 760px;-moz-border-radius: 3px;border-radius: 3px;margin-bottom: 5px;color: #666;background: url(../images/input_bg.gif) repeat-x top;}
   </style>
  </head>
  
  <body>
<form id="pageFrom" action="" enctype="multipart/form-data" method="post">
        <input type="hidden" id="flag" name="flag" />
        <input type="hidden" id="gongyingshangid" name="gongyingshangid" value="${requestScope.id }"/>
  		<table width="100%" border="0" align="center" cellpadding="5" cellspacing="5" class="formTableNew">
  			<tr>
  			  <td align="right">供应商名称：</td>
  			  <td align="left">
  			    <input  type="text"  id="gongyingshangname" maxlength="50" name="gongyingshangname" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  	<img src="<%=request.getContextPath() %>/images/xh.png" align="absmiddle"></img>
  			  </td>
  			  </tr>
  			<tr>
  			  <td align="right">供应商地址：</td>
  			   <td align="left">
  			    <input  type="text"  id="gongyingshangdizhi" maxlength="50" name="gongyingshangdizhi" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			   </td>
  			</tr>
  			<tr>
  			  <td align="right">联系方式：</td>
  			  <td align="left">
  			    <input  type="text"  id="lianxifangshi" maxlength="50" name="lianxifangshi" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  </td>
  			  </tr>
  			<tr>
  			  <td align="right">联系人：</td>
  			   <td align="left">
  			    <input  type="text"  id="lianxiren" maxlength="50" name="lianxiren" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			   </td>
  			</tr>
  			<tr>
  			  <td align="right">供应品(服务)名称：</td>
  			  <td align="left">
  			  	 <input  type="text"  id="gongyingpinname" maxlength="50" name="gongyingpinname" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  </td>
  			  </tr>
  			<tr>
  			  <td align="right">首次列入日期：</td>
  			  <td align="left">
  			    <input  type="text"  id="shoucilieruriqi" maxlength="50"  name="shoucilieruriqi" onClick="WdatePicker()" style="border: 1px solid #999;padding: 5px;width: 250px;height:25px;"  value="" />
  			  </td>
  			</tr>
  			<tr>
  			  <td align="right">供应商资质：</td>
  			  <td align="left">
  			    <jsp:include page="../fileupload/attachment.jsp?id=${requestScope.id }&column=GONGYINGSHANGZIZHI&show=n" ></jsp:include>
  			  </td>
  			  </tr>
  			<tr>
  			  <td align="right">供应商评价：</td>
  			  <td align="left">
  			  	<jsp:include page="../fileupload/attachment.jsp?id=${requestScope.id }&column=GONGYINGSHANGPINGJIA&show=n" ></jsp:include>
  			  </td>
  			</tr>
 			<tr>
		    <td align="right"  >备注：</td>
		    <td colspan="3">
		    	<div class="div">
					<textarea rows="5" cols="100" id="REMARK" name="REMARK" onkeydown="countlen1(this);" style="width: 250px;"></textarea>
				</div>	
		    </td>
		  </tr>
		</table>
		<table width="100%" border="0" align="center" class="formTableNew">
		  <tr>
			<td align="center">
		    	<input id="saveBtn" type="button" value="提 交" class="form_bt_orange" />
		    	<input type="button" id="closeBtn" value="取 消" class="form_bt_grey" />
		    </td>
		  </tr>
		</table>
	<!--表单结束-->
	</form>
 
  </body>
</html>
